package org.grow.leavejpa.service;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Service;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: xwg
 * @CreateDate: 21-6-8
 */
@Service
public class EntryPointHandler implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
         System.out.println("实在没有通行证，没有临时正没有正常通行证");
                        httpServletResponse.setStatus(990);
                        httpServletResponse.getWriter().println("没有任何通行证"+e.getMessage());
                        httpServletResponse.flushBuffer();
    }
}
